@extends('layouts.default')
@section('main')
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
                            class="icon-home"></i> 首页</a>
                <a href="{{url('zone/list')}}" class="tip-bottom">城市管理</a>
                <a href="#" class="current">创建城市</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span9">
                    <div class="widget-box">
                        <div class="widget-title">
						<span class="icon"> <i class="icon-align-justify"></i>
						</span>
                            <h5>创建城市</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <form action="{{url('zone/create')}}" id="adForm" method="post" class="form-horizontal">
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>城市名称 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="name"  placeholder="城市名称" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>城市首字母 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="alpha"  placeholder="城市首字母" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>级别 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="level"  placeholder="level"  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>全拼 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="pinyin"  placeholder="全拼"  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">父地区 :</label>
                                    <div class="controls">
                                        <select  name="upid" >
                                            <option value="0">请选择</option>
                                            {{--@foreach($pLists as $v)<option value="" >{{$v->name}}</option>@endforeach--}}
                                            @foreach($pLists as $v)
                                                <option value="{{$v->id}}">{{$v->name}}</option>
                                                @endforeach
                                        </select>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>是否有门店 :</label>
                                    <div class="controls">
                                        <select  name="is_store" >
                                            <option value="">请选择</option>
                                            <option value="0">有</option>
                                            <option value="1">暂无</option>
                                        </select>
                                    </div>
                                </div>
                                <input type="hidden" class="span11" name="formType" value="create" />
                                <div class="form-actions">
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <button type="button" id="doSave" class="btn btn-success">确认修改</button>
                                </div>
                            </form>
                            @include('errors.list')
                            @include('message.flash')
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
//        $("#doSave").click(function(){
//            $(this).attr('disabled','disabled');
//
//            ajaxRequest($('#adForm').serializeArray(),$('#adForm').attr('action'),function(data){
//                if(data.status){
//                    alert(data.message);
//                    window.location.href = data.forwardUrl;
//                }else{
//                    $("#doSave").removeAttr('disabled');
//
//                    alert(data.message);
//                }
//            });
//        });
        $("#doSave").click(function(){
            $(this).attr('disabled','disabled');
            ajaxRequest($('#adForm').serializeArray(),$("#adForm").attr('action'),function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href=data.forwardUrl;
                }else{
                    $('#doSave').removeAttr('disabled');
                    alert(data.message);
                }
            });
        });
    </script>
@stop
